<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<%@ include file="/web/header.jsp" %>
</head>
<body style="bacground:#f1f1f1">
<!-- http://127.0.0.1:8081/ -->
<div class="window">
<fieldset class="layui-elem-field">
 <legend>登录</legend>
 <div class="layui-field-box">
	<form class="layui-form layui-form-pane">
	 <div class="layui-form-item">
	  <label class="layui-input-label">账号
	  </label>
	  <div class="layui-input-block">
	   <input type="text" name="code" required lay-verify="required"
	   	placeholder="请输入账号" autocomplete="off" class="layui-input">
	  </div>
	 </div>
	 <div class="layui-form-item">
	  <label class="layui-input-label">密码
	  </label>
	  <div class="layui-input-block">
	   <input type="password" name="pass" required lay-verify="required"
	   	placeholder="请输入密码" autocomplete="off" id='login' class="layui-input">
	  </div>
	 </div>
	  <div class="layui-from-item">
	  <div class="layui-input-inline">	  
	 	<input type="button"  value='登录' class="layui-btn" lay-submit lay-filter="login">
	 	<input type="reset" value='重置' class="layui-btn layui-btn-primary">
	  </div>
	  <input type="button" value="返回注册" class="layui-btn"  onclick="toHref('/web/reg.jsp')">
	 </div>
	 <input type="hidden" name="action" value="login">
	</form>
</div>

</fieldset>
</div>
<script type="text/javascript">
// var form=layui.form;
// var $=layui.jquery;
// var layer=layui.layer;
// form.on("submit(reg)",function(data){
// 	console.log(data.field)
// 	$.ajax({
// 		url:base.app+"/EmployeeServlet",
// 		type:"post",
// 		data:data.field,
// 		dataType:"text",
// 		success:function(data){
// // 			console.log(data)
// 		if(data==1){
// 			layer.msg("注册成功")
// 		}else if(data=="repeat"){
// 			layer.msg("注册失败，账号重复")
// 		}else{
// 			layer.msg("注册失败")
// 		}
// 		}
// 	});
// });
formOnSubmit('login','/EmployeeServlet','text',function(data){
	console.log()
		if(data==1){
		layer.msg("登陆成功",{time:2000},function(){
			toHref("/web/page/main.jsp");
		});
	}else if(data==2){
		layer.msg("登陆失败，密码错误")
	}else{
		layer.msg("登陆失败，账号不存在")
	}
})
		
</script>
</html>